<?php
//永不超时 -cli   不能使用nginx apache
set_time_limit(0);
include __DIR__.'/function.php';
require __DIR__.'/vendor/autoload.php';
use QL\QueryList;
$db = new PDO('mysql:host=localhost;dbname=bd_laravel;charset=utf8mb4','root','root');
//查询出所有的文章的数据
$sql = "select id,url from bd_articles where body = ''";
//查询
$rows = $db->query($sql)->fetchAll(PDO::FETCH_ASSOC);
//直接进行循环
//
foreach($rows as $val){
    $url = $val['url'];
    $html = http_request($url);
    $ql = QueryList::html($html);
    //获取元素下面的html内容
    $rt = $ql->find('.bd')->html();
    $updatesql = "update bd_articles set body = ? where id = ?";
    //执行sql的缓冲区
    $stmt = $db->prepare($updatesql);
    $stmt->execute([$rt,$val['id']]);
}
?>